package com.fivefaces.ide.plugins.impl;

import com.fivefaces.ide.plugins.ConsoleExecutablePathService;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import static com.fivefaces.ide.plugins.Constants.WINDOWS_EXTENSION;

/**
 * User: imran.khan
 * Date: 6/04/11
 * Time: 2:11 PM
 */
public class WindowsCommandBuilder extends AbstractCommandBuilder {

    public WindowsCommandBuilder(ConsoleExecutablePathService consoleExecutablePathService) {
        super(consoleExecutablePathService);
    }

    protected FileWriter writeFile(String path, FileWriter fileWriter, File executeFile) throws IOException {
        fileWriter = new FileWriter(executeFile);
        fileWriter.write("@echo off\n");
        fileWriter.write("cd \"" + path + "\"\n");
        fileWriter.write("start " + getExecutablePath());
        return fileWriter;
    }

    protected String getFileExtension() {
        return WINDOWS_EXTENSION;
    }

    protected void makeFileExecutable(String result) {
        logger.debug("Do nothing.");
    }
}
